import tool from "@/utils/tool";
import sysSecApi from "@/api/sec/sysSecApi";

const secLevelUtil = {}

secLevelUtil.secSubjectList = () =>{
	const sec = tool.data.get('SYS_SEC_LEVEL')
	const r = sec.map((item) => {
		//console.log(typeof item.level.toString())
		return {
			value: item.level.toString(),
			label: item.subjectName
		}
	})
	return r
}

secLevelUtil.secObjectList = () =>{
	const sec = tool.data.get('OBJ_SEC_LEVEL')
	const r = sec.map((item) => {
		//console.log(typeof item.level.toString())
		return {
			value: item.level.toString(),
			label: item.objectName
		}
	})
	return r
}

secLevelUtil.secSubjectName = (value) => {
	const secList = tool.data.get('SYS_SEC_LEVEL')
	if (!secList) {
		return '需重新登录'
	}
	console.log(value);
	const sec = secList.find(function (item)  {
		console.log("item.value:",item.level)
		console.log("value:",value)
		return item.level == value
	})
	if (!sec) {
		return '无密级'
	}
	return sec.subjectName
}

secLevelUtil.secObjectName = (value) => {
	const secList = tool.data.get('SYS_SEC_LEVEL')
	if (!secList) {
		return '需重新登录'
	}
	const sec = secList.find((item) => item.level == value)
	if (!sec) {
		return '无密级'
	}
	return sec.objectName
}


export default secLevelUtil
